package com.piggy.common.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 发票验真失败原因
 */
@Getter
@AllArgsConstructor
public enum InvoiceVerifyEnum {
    A("9999","查验失败","查验失败，业务出现异常，请提交工单咨询"),
    B("0002","超过该张票当天查验次数","此发票今日查询次数已达上限（5次），请次日查询"),
    C("0005","请求不合法","发票信息有误，请核对后再查询"),
    D("0006","发票信息不一致","发票信息有误，请核对后再查询"),
    E("0009","发票不存在","查验失败，业务出现异常，请提交工单咨询"),
    F("1004","已超过最大查验量","已超过最大查验量，请提交工单咨询"),
    G("1005","查询发票不规范","信息有误，请核对后再查询"),
    H("1006","查验异常","发票信息有误，请核对后再查询"),
    I("1007","该批次已过期，请重新更换批次号查验","该批次已过期，请重新更换批次号查验"),
    J("1008","字段不能为空","发票请求参数不能为空"),
    K("1009","参数长度不正确","参数长度不符合规范，确认参数，再次查验"),
    L("1014","日期当天的不能查验","日期当天的不能查验，请隔天再查"),
    M("1015","超过5年的不能查验","超过5年的不能查验"),
    N("1020","查验失败","没有查验权限"),
    O("1021","网络超时","税局维护升级，暂时无法查验，请提交工单咨询")

    ;
    /**
     * 类型
     */
    private final String verifyResult;

    /**
     * 查验结果信息
     */
    private final String verifyMessage;

    /**
     * 描述
     */
    private final String info;

    public static List<String> getByVerifyResult(String verifyResult){
        InvoiceVerifyEnum[] values = InvoiceVerifyEnum.values();
        List<String> res=new ArrayList<>();
        for (InvoiceVerifyEnum value : values) {
            if(value.getVerifyResult().equals(verifyResult)){
                res.add(0,value.getVerifyMessage());
                res.add(1,value.getInfo());
                return res;
            }
        }
        return res;
    }

}
